<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<p:dialog id="role_resource_edit_dialog" widgetVar="role_resource_edit_var" modal="true"
		header="角色资源关联" resizable="false" width="750">

		<h:form prependId="false" id="role_resource_edit_form">
			<p:dataTable id="role_resource_data_table" value="#{resourceBean.lazyRoleResData}"
				var="data" paginator="true" rows="10" paginatorPosition="bottom"
				paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
				currentPageReportTemplate="{currentPage}/{totalPages}"
				selection="#{resourceBean.roleReses}" emptyMessage="#{msgs.emptyResult}">
				<f:facet name="header">资源角色权限列表
					<div style="text-align: right; position: relative; margin: -13px -5px 0px 0px; vertical-align: middle">
						<p:commandButton value="#{msgs.btnNew}" icon="#{comm.newClass}"
							actionListener="#{roleBean.initAddRoleResource}" 
							oncomplete="role_edit_var.show();"/>
					</div>
				</f:facet>
	
				<p:column headerText="编号" style="width: 15%; text-align: center;" styleClass="substring">
					<h:outputText value="#{data.role.code}" title="#{data.role.code}" />
				</p:column>
				<p:column headerText="名称" style="width: 20%; text-align: center;" styleClass="substring">
					<h:outputText value="#{data.role.name}" title="#{data.role.name}" />
				</p:column>
				<p:column headerText="关联" style="width: 7%; text-align: center;">
					<p:selectBooleanCheckbox value="#{data.permission.communicate}"/>
				</p:column>
				<p:column headerText="审核" style="width: 7%; text-align: center;">
					<p:selectBooleanCheckbox value="#{data.permission.check}"/>
				</p:column>
				<p:column headerText="删除" style="width: 7%; text-align: center;">
					<p:selectBooleanCheckbox value="#{data.permission.drop}"/>
				</p:column>
				<p:column headerText="修改" style="width: 7%; text-align: center;">
					<p:selectBooleanCheckbox value="#{data.permission.modify}"/>
				</p:column>
				<p:column headerText="新增" style="width: 7%; text-align: center;">
					<p:selectBooleanCheckbox value="#{data.permission.add}"/>
				</p:column>
				<p:column headerText="查询" style="width: 7%; text-align: center;">
					<p:selectBooleanCheckbox value="#{data.permission.query}"/>
				</p:column>
			</p:dataTable>
			
			<div style="text-align: center; margin-top: 5px;">
				<p:commandButton icon="#{comm.saveClass}" value="#{msgs.btnSave}" action="#{resourceBean.communicateRoleRes}"
					oncomplete="handleRoleResource(xhr, status, args);" update=":option_info" />
				<p:commandButton icon="#{comm.cancelClass}" value="#{msgs.btnCancel}" type="button" onclick="role_resource_edit_var.hide();"/>
			</div>
		</h:form>
		<script type="text/javascript">
			function handleRoleResource(xhr, status, args) {
				if(args.option_result == 'success') {
					role_resource_edit_var.hide();
				}
			}
		</script>
	</p:dialog>

</ui:composition>